/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Cali.java
 *
 * Created on 10-dic-2009, 18:52:06
 */
package GUI;

import Controlador.Controlador;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author Administrador
 */
public class GUI_Previsualizacion extends javax.swing.JDialog {

    private static Controlador controlador;
    private static JPanel mapa;
    private boolean coordenadas1;
    private boolean coordenadas2;
    private double lat1, lat2, long1, long2;
    private int pixelX,pixelY;

    /** Creates new form Cali */
    public GUI_Previsualizacion(JFrame parent) {
        super(parent, true);
        controlador = InicioAplicacion.getControlador();
        initComponents();
        mapa = PMapa;
        coordenadas1 = false;
        coordenadas2 = false;
        centrarAplicacion();
        parent.setVisible(false);
        setVisible(true);
    }

    public static JPanel getDisplayMapa() {
        return mapa;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        BGModoCalibracion = new javax.swing.ButtonGroup();
        JDPMapa = new javax.swing.JDesktopPane();
        PMapa = new javax.swing.JPanel();
        JDPPixel = new javax.swing.JPanel();
        LabelX = new javax.swing.JLabel();
        LabelY = new javax.swing.JLabel();
        TXTPixelX = new javax.swing.JTextField();
        TXTPixelY = new javax.swing.JTextField();
        JDPCargar = new javax.swing.JPanel();
        BCargar = new javax.swing.JButton();
        JDPCoordenadas = new javax.swing.JPanel();
        LabelLat = new javax.swing.JLabel();
        LabelLong = new javax.swing.JLabel();
        TXTCoorLat = new javax.swing.JTextField();
        TXTCoorLong = new javax.swing.JTextField();
        JDPCargar1 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Calibración de mapas");
        setResizable(false);

        JDPMapa.setBackground(new java.awt.Color(235, 233, 237));
        JDPMapa.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true), "Mapa", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14))); // NOI18N
        JDPMapa.setForeground(new java.awt.Color(235, 233, 237));
        JDPMapa.setPreferredSize(new java.awt.Dimension(650, 560));

        PMapa.setToolTipText("");
        PMapa.setName("Mapa"); // NOI18N
        PMapa.setPreferredSize(new java.awt.Dimension(633, 548));
        PMapa.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                PMapaMouseDragged(evt);
            }
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                PMapaMouseMoved(evt);
            }
        });

        javax.swing.GroupLayout PMapaLayout = new javax.swing.GroupLayout(PMapa);
        PMapa.setLayout(PMapaLayout);
        PMapaLayout.setHorizontalGroup(
            PMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 633, Short.MAX_VALUE)
        );
        PMapaLayout.setVerticalGroup(
            PMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 548, Short.MAX_VALUE)
        );

        PMapa.setBounds(10, 20, 633, 548);
        JDPMapa.add(PMapa, javax.swing.JLayeredPane.DEFAULT_LAYER);

        JDPPixel.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true), "Pixel X,Y", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14))); // NOI18N

        LabelX.setText("X:");

        LabelY.setText("Y:");

        TXTPixelX.setEditable(false);

        TXTPixelY.setEditable(false);

        javax.swing.GroupLayout JDPPixelLayout = new javax.swing.GroupLayout(JDPPixel);
        JDPPixel.setLayout(JDPPixelLayout);
        JDPPixelLayout.setHorizontalGroup(
            JDPPixelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JDPPixelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LabelX, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TXTPixelX, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(37, 37, 37)
                .addComponent(LabelY, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(TXTPixelY, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(102, Short.MAX_VALUE))
        );
        JDPPixelLayout.setVerticalGroup(
            JDPPixelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JDPPixelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(JDPPixelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LabelX)
                    .addComponent(TXTPixelX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LabelY)
                    .addComponent(TXTPixelY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        JDPCargar.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true), "Imagen", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14))); // NOI18N

        BCargar.setText("Cargar Imagen");
        BCargar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCargarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout JDPCargarLayout = new javax.swing.GroupLayout(JDPCargar);
        JDPCargar.setLayout(JDPCargarLayout);
        JDPCargarLayout.setHorizontalGroup(
            JDPCargarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JDPCargarLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(BCargar, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE)
                .addContainerGap())
        );
        JDPCargarLayout.setVerticalGroup(
            JDPCargarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JDPCargarLayout.createSequentialGroup()
                .addComponent(BCargar, javax.swing.GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE)
                .addContainerGap())
        );

        JDPCoordenadas.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true), "Coordenadas Reales", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14))); // NOI18N

        LabelLat.setText("Latitud");

        LabelLong.setText("Longitud");

        javax.swing.GroupLayout JDPCoordenadasLayout = new javax.swing.GroupLayout(JDPCoordenadas);
        JDPCoordenadas.setLayout(JDPCoordenadasLayout);
        JDPCoordenadasLayout.setHorizontalGroup(
            JDPCoordenadasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JDPCoordenadasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(JDPCoordenadasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(LabelLat, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                    .addComponent(LabelLong, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(JDPCoordenadasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(TXTCoorLong)
                    .addComponent(TXTCoorLat, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE))
                .addContainerGap())
        );
        JDPCoordenadasLayout.setVerticalGroup(
            JDPCoordenadasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JDPCoordenadasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(JDPCoordenadasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LabelLat)
                    .addComponent(TXTCoorLat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(JDPCoordenadasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LabelLong)
                    .addComponent(TXTCoorLong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        JDPCargar1.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true), "Zoom", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14))); // NOI18N

        jButton2.setFont(new java.awt.Font("Arial", 1, 14));
        jButton2.setText("ZOOM ++");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setFont(new java.awt.Font("Arial", 1, 14));
        jButton3.setText("ZOOM --");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout JDPCargar1Layout = new javax.swing.GroupLayout(JDPCargar1);
        JDPCargar1.setLayout(JDPCargar1Layout);
        JDPCargar1Layout.setHorizontalGroup(
            JDPCargar1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JDPCargar1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(JDPCargar1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE)
                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE))
                .addContainerGap())
        );
        JDPCargar1Layout.setVerticalGroup(
            JDPCargar1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JDPCargar1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton2)
                .addGap(44, 44, 44)
                .addComponent(jButton3)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1016, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(JDPMapa, javax.swing.GroupLayout.PREFERRED_SIZE, 653, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(JDPCargar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(JDPCargar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(JDPCoordenadas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(JDPPixel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 655, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(JDPCargar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(JDPCargar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(JDPPixel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(JDPCoordenadas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(JDPMapa, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 578, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(77, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void PMapaMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PMapaMouseDragged

}//GEN-LAST:event_PMapaMouseDragged

    private void PMapaMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PMapaMouseMoved
        TXTPixelX.setText(String.valueOf(evt.getX()));
        TXTPixelY.setText(String.valueOf(evt.getY()));
        pixelX = evt.getX();
        pixelY = evt.getY();
}//GEN-LAST:event_PMapaMouseMoved

    private void BCargarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BCargarActionPerformed
        //        controlador.previsualizar();
        //        PMapa.setBorder(controlador.getPrevisualizacion());
}//GEN-LAST:event_BCargarActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        //        controlador.getPrevisualizacion().zoomMas();
}//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        //        controlador.getPrevisualizacion().zoomMenos();
}//GEN-LAST:event_jButton3ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BCargar;
    private javax.swing.ButtonGroup BGModoCalibracion;
    private javax.swing.JPanel JDPCargar;
    private javax.swing.JPanel JDPCargar1;
    private javax.swing.JPanel JDPCoordenadas;
    private javax.swing.JDesktopPane JDPMapa;
    private javax.swing.JPanel JDPPixel;
    private javax.swing.JLabel LabelLat;
    private javax.swing.JLabel LabelLong;
    private javax.swing.JLabel LabelX;
    private javax.swing.JLabel LabelY;
    private javax.swing.JPanel PMapa;
    private javax.swing.JTextField TXTCoorLat;
    private javax.swing.JTextField TXTCoorLong;
    private javax.swing.JTextField TXTPixelX;
    private javax.swing.JTextField TXTPixelY;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    // End of variables declaration//GEN-END:variables

    private void centrarAplicacion() {
        int width = this.getWidth();
        int height = this.getHeight();
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screen.width - width) / 2;
        int y = (screen.height - height) / 2;
        setBounds(x, y, width, height);
    }
}
